home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------ shape_calls.c -------------------------------*/
- /* Copyright 1989 Brown University -- Jeffrey Vogel */
- /*----------------------------------------------------------------------------*/
-
-
- /*--------------------------------- Includes ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- #include "qd_local.h"
-
-
-
- /*--------------------------------- DrawLine ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- DrawLine(p1, p2)
- Point p1, p2;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR DrawLine: QuickDraw not initialized.");
- return;
- }
-
- XDrawLine(QDdisplay, QDwindow, QDgc,
- p1.x, p1.y,
- p2.x, p2.y);
- XFlush(QDdisplay);
- }
-
-
- /*-------------------------------- EraseLine ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- EraseLine(p1, p2)
- Point p1, p2;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR EraseLine: QuickDraw not initialized.");
- return;
- }
-
- XSetFunction(QDdisplay, QDgc, GXclear);
- XDrawLine(QDdisplay, QDwindow, QDgc,
- p1.x, p1.y,
- p2.x, p2.y);
- XFlush(QDdisplay);
- XChangeGC(QDdisplay, QDgc, GCFunction, &QDgcValues);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*-------------------------------- FrameRect ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- FrameRect(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR FrameRect: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR FrameRect: Invalid rectangle.");
- return;
- }
-
- XDrawRectangle(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top);
- XFlush(QDdisplay);
- }
-
-
- /*-------------------------------- PaintRect ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- PaintRect(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR PaintRect: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR PaintRect: Invalid rectangle.");
- return;
- }
-
- XFillRectangle(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1);
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*-------------------------------- InvertRect --------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- InvertRect(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR InvertRect: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR InvertRect: Invalid rectangle.");
- return;
- }
-
- XFillRectangle(QDdisplay, QDwindow, QDinvertgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1);
- XFlush(QDdisplay);
- }
-
-
- /*-------------------------------- EraseRect ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- EraseRect(rect)
- Rect rect;
- {
- int offset = QDgcValues.line_width;
-
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR EraseRect: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR EraseRect: Invalid rectangle.");
- return;
- }
-
- XSetFunction(QDdisplay, QDgc, GXclear);
- XFillRectangle(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1);
- XFlush(QDdisplay);
- XChangeGC(QDdisplay, QDgc, GCFunction, &QDgcValues);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- /*-------------------------------- FrameOval ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- FrameOval(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR FrameOval: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR FrameOval: Invalid rectangle.");
- return;
- }
-
- XDrawArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- 0, 360 * 64);
- XFlush(QDdisplay);
- }
-
- /*-------------------------------- PaintOval ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- PaintOval(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR PaintOval: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR PaintOval: Invalid rectangle.");
- return;
- }
-
- XFillArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 0, 360 * 64);
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*-------------------------------- InvertOval --------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- InvertOval(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR InvertOval: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR InvertOval: Invalid rectangle.");
- return;
- }
-
- XFillArc(QDdisplay, QDwindow, QDinvertgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 0, 360 * 64);
- XFlush(QDdisplay);
- }
-
- /*-------------------------------- EraseOval ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- EraseOval(rect)
- Rect rect;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR EraseOval: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR EraseOval: Invalid rectangle.");
- return;
- }
-
- XSetFunction(QDdisplay, QDgc, GXclear);
- XFillArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 0, 360 * 64);
- XFlush(QDdisplay);
- XChangeGC(QDdisplay, QDgc, GCFunction, &QDgcValues);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*--------------------------------- FrameArc ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- FrameArc(rect, start, angle)
- Rect rect;
- int start, angle;
- {
- if (!QDrunning) {
- QDerror("ERROR FrameArc: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR FrameArc: Invalid rectangle.");
- return;
- }
-
- XDrawArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- 64 * (90 - start - angle), 64 * angle);
- XFlush(QDdisplay);
- }
-
-
-
-
- /*--------------------------------- PaintArc ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- PaintArc(rect, start, angle)
- Rect rect;
- int start, angle;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR PaintArc: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR PaintArc: Invalid rectangle.");
- return;
- }
-
- XFillArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 64 * (90 - start - angle), 64 * angle);
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
-
-
- /*-------------------------------- InvertArc ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- InvertArc(rect, start, angle)
- Rect rect;
- int start, angle;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR InvertArc: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR InvertArc: Invalid rectangle.");
- return;
- }
-
- XFillArc(QDdisplay, QDwindow, QDinvertgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 64 * (90 - start - angle), 64 * angle);
- XFlush(QDdisplay);
- }
-
-
-
- /*--------------------------------- EraseArc ---------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- EraseArc(rect, start, angle)
- Rect rect;
- int start, angle;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR EraseArc: QuickDraw not initialized.");
- return;
- }
- if ((rect.left > rect.right) ||
- (rect.top > rect.bottom)) {
- QDerror("ERROR EraseArc: Invalid rectangle.");
- return;
- }
-
- XSetFunction(QDdisplay, QDgc, GXclear);
- XFillArc(QDdisplay, QDwindow, QDgc,
- rect.left, rect.top,
- rect.right - rect.left + 1,
- rect.bottom - rect.top + 1,
- 64 * (90 - start - angle), 64 * angle);
- XChangeGC(QDdisplay, QDgc, GCFunction, &QDgcValues);
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
- /*------------------------------- PaintCircle --------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- PaintCircle(x, y, radius)
- int x, y, radius;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR PaintCircle: QuickDraw not initialized.");
- return;
- }
- if (radius <= 0) {
- QDerror("ERROR PaintCircle: Invalid circle.");
- return;
- }
-
- XFillArc(QDdisplay, QDwindow, QDgc,
- x-radius, y-radius,
- 2*radius + 1, 2*radius + 1,
- 0, (64 * 360));
-
- XFlush(QDdisplay);
- }
-
-
-
-
-
- /*------------------------------- FrameCircle --------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- FrameCircle(x, y, radius)
- int x, y, radius;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR FrameCircle: QuickDraw not initialized.");
- return;
- }
- if (radius <= 0) {
- QDerror("ERROR FrameCircle: Invalid circle.");
- return;
- }
-
- XDrawArc(QDdisplay, QDwindow, QDgc,
- x-radius, y-radius,
- 2*radius, 2*radius,
- 0, (64 * 360));
-
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- /*------------------------------- EraseCircle --------------------------------*/
- /*----------------------------------------------------------------------------*/
-
- void
- EraseCircle(x, y, radius)
- int x, y, radius;
- {
- /*** error check ***/
- if (!QDrunning) {
- QDerror("ERROR EraseCircle: QuickDraw not initialized.");
- return;
- }
- if (radius <= 0) {
- QDerror("ERROR EraseCircle: Invalid circle.");
- return;
- }
-
- XSetFunction(QDdisplay, QDgc, GXclear);
- XFillArc(QDdisplay, QDwindow, QDgc,
- x-radius, y-radius,
- 2*radius + 1, 2*radius + 1,
- 0, (64 * 360));
- XChangeGC(QDdisplay, QDgc, GCFunction, &QDgcValues);
- XFlush(QDdisplay);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-